{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "dotnet_interactive": {
     "language": "csharp"
    },
    "polyglot_notebook": {
     "kernelName": "csharp"
    },
    "vscode": {
     "languageId": "polyglot-notebook"
    }
   },
   "outputs": [],
   "source": [
    "#load \"..\\Extension\\LoadBaseTool.csx\"\n",
    "using BaseTool;"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "dotnet_interactive": {
     "language": "mermaid"
    },
    "polyglot_notebook": {
     "kernelName": "mermaid"
    },
    "vscode": {
     "languageId": "polyglot-notebook"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div class=\"mermaidMarkdownContainer\" style=\"background-color:white\">\r\n",
       "<link rel=\"stylesheet\" href=\"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.0/css/all.min.css\">\r\n",
       "<div id=\"65676cbfe9e44007a4aa3cc6403ba491\"></div>\r\n",
       "<script type=\"module\">\r\n",
       "\r\n",
       "            import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@10.6.1/dist/mermaid.esm.min.mjs';\r\n",
       "            let renderTarget = document.getElementById('65676cbfe9e44007a4aa3cc6403ba491');\r\n",
       "            try {\r\n",
       "                const {svg, bindFunctions} = await mermaid.mermaidAPI.render( \r\n",
       "                    'mermaid_65676cbfe9e44007a4aa3cc6403ba491', \r\n",
       "                    `classDiagram\n",
       "    class Base {\n",
       "      +ToString() : \"Base\"\n",
       "    }\n",
       "    class A {\n",
       "      +ToString() : \"A\"\n",
       "    }\n",
       "    class B {\n",
       "      +ToString() : \"B\"\n",
       "    }\n",
       "    Base <|-- A : 继承\n",
       "    Base <|-- B : 继承`);\r\n",
       "                renderTarget.innerHTML = svg;\r\n",
       "                bindFunctions?.(renderTarget);\r\n",
       "            }\r\n",
       "            catch (error) {\r\n",
       "                console.log(error);\r\n",
       "            }\r\n",
       "</script>\r\n",
       "</div>\r\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "classDiagram\n",
    "    class Base {\n",
    "      +ToString() : \"Base\"\n",
    "    }\n",
    "    class A {\n",
    "      +ToString() : \"A\"\n",
    "    }\n",
    "    class B {\n",
    "      +ToString() : \"B\"\n",
    "    }\n",
    "    Base <|-- A : 继承\n",
    "    Base <|-- B : 继承"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "dotnet_interactive": {
     "language": "csharp"
    },
    "polyglot_notebook": {
     "kernelName": "csharp"
    },
    "vscode": {
     "languageId": "polyglot-notebook"
    }
   },
   "outputs": [],
   "source": [
    "public class Base\n",
    "{\n",
    "    public override string ToString() => \"Base\";\n",
    "}\n",
    "\n",
    "public class A:Base\n",
    "{\n",
    "    public override string ToString() => \"A\";\n",
    "}\n",
    "\n",
    "public class B:Base\n",
    "{\n",
    "    public override string ToString() => \"B\";\n",
    "}\n",
    "\n",
    "public void FormatShow(Base _obj) => _obj.Dump();\n",
    "public void FormatShow(A _obj) => _obj.Dump();\n",
    "public void FormatShow(B _obj) => _obj.Dump();"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "即使下面的 `_obj` 被定义为 `Base` 类型，但他实际上还是 `A` 类型，因此还是调用 `FormatShow(A _obj)`\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "dotnet_interactive": {
     "language": "csharp"
    },
    "polyglot_notebook": {
     "kernelName": "csharp"
    },
    "vscode": {
     "languageId": "polyglot-notebook"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "A\r\n"
     ]
    }
   ],
   "source": [
    "Base _obj = new A();\n",
    "FormatShow(_obj);"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": ".NET (C#)",
   "language": "C#",
   "name": ".net-csharp"
  },
  "language_info": {
   "name": "python"
  },
  "polyglot_notebook": {
   "kernelInfo": {
    "defaultKernelName": "csharp",
    "items": [
     {
      "aliases": [],
      "name": "csharp"
     }
    ]
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
